<?php

	/**
	 * @see Zend_View_Helper_Placeholder_Container_Standalone
	 */
	require_once 'Zend/View/Helper/Placeholder/Container/Standalone.php';	
	
	
	class Bike_View_Helper_Ext extends Zend_View_Helper_Placeholder_Container_Standalone
	{
	    const CLASS_NAME_PREFIX = 'Bike_Js';

	    protected $_regKey = __CLASS__;

	    public function ext()
	    {	    	$args = func_get_args();
	    	$ClassNamePostfix = array_shift($args);
	    	if(is_null($ClassNamePostfix))
	    	{
	    		return $this;
	   		}
	   		array_unshift($args, $ClassNamePostfix);
	   		return call_user_func_array(array($this, 'getExtObject'), $args);
	    }

	    protected function getExtObject()
	    {	    	$args = func_get_args();
	    	$ClassNamePostfix = array_shift($args);
	    	if(substr($ClassNamePostfix, 0, 4) != 'Ext_')
			{
				$ClassNamePostfix = 'Ext_'.$ClassNamePostfix;
			}
			array_unshift($args, $ClassNamePostfix);
			return call_user_func_array(array(self::CLASS_NAME_PREFIX, 'factory'), $args);
	   	}

	    public function set($Alias, $ClassNamePostfix=null, array $Options=null)
	    {
		    $args = func_get_args();
	    	$Alias = array_shift($args);
		    $this->$Alias = call_user_func_array(array($this, 'getExtObject'), $args);
       		return $this->$Alias;
	    }

	    public function get($Alias=null)
	    {	    	if(!isset($this->$Alias))
            {
            	require_once 'Zend/View/Exception.php';
            	throw new Zend_View_Exception('Undefined alias "'.$Alias.'"');
            }
            return $this->$Alias;
	    }

	}
